package account.model;

import java.text.Collator;
import java.util.ArrayList;
import java.util.Observable;
import java.util.Observer;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;

import javax.swing.AbstractListModel;

import prototyping.client.AbstractMessage;

public class HelpListModel extends AbstractListModel implements Observer{

	private static final long serialVersionUID = 1L;
	
	private ArrayList<AbstractMessage> tempMessage = new ArrayList<>();
	private TreeSet<AbstractMessage> message = new TreeSet<AbstractMessage>();

	public HelpListModel() {}

	public AbstractMessage getElementAt(int index) {
		tempMessage.clear();
		tempMessage.addAll(message);
		return tempMessage.get(index);
	}

	public int getSize() {
		return message.size();
	}

	public int getValue(){
		for(int i = 1; i < message.size(); i++){
			if(message.size() > +1){
				return message.size();
			}
		}
		return message.size();
	}
	
	//voeg nieuwe vragen toe aan wachtrij
	public void update(Observable o, Object arg) {
		AbstractMessage amsg = (AbstractMessage)arg;
		if(amsg.isDone()){
			deleteMessage(amsg);
		}
		else{
			message.add(amsg);
			fireIntervalAdded(this, message.size(), message.size());
		}
	}
	
	//verwijder geselecteerde item uit wachtrij
	public void deleteMessage(AbstractMessage aMsg){
		message.remove(aMsg);
		fireIntervalRemoved(this, message.size(), message.size());
	}

}
